s1 = input()
s2 = input()
i = 0
while i < len(s1) and i < len(s2):
    if s1[i] == s2[i]:
        i += 1
    else:
        break
print(s1[0:i])
